package com.example.whac_a_mole;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class Activity_selected extends AppCompatActivity {
    private static final String TAG = "LSK";
 private  int count=0;
 private Button button_sim;
 private Button button_mid;
 private Button button_max;
 private Button button_top;
 private Button button_autor;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //增加注册登录功能
        /*
        初级难度:1.6秒
        中级难度:0.8秒
        高级难度:0.4秒
        存储
        高分榜:SharedPreferences存储
        用户登录注册:SQlite存储
        */
        button_sim=findViewById(R.id.button_sim);
        button_mid=findViewById(R.id.button_mid);
        button_max=findViewById(R.id.button_max);
        button_top=findViewById(R.id.button_top);
        button_autor=findViewById(R.id.button_autor);

        //获取user
        getIntent().getStringExtra("user");

        //简单难度
        button_sim.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            Intent intent=new Intent(Activity_selected.this, Activity_game.class);
            int time=1600;
            intent.putExtra("time",time);
            intent.putExtra("user",getIntent().getStringExtra("user"));
            startActivity(intent);


            }
        });
        //中级难度
        button_mid.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int time=800;
//                DataBase dataBase=new DataBase(Activity_selected.this);
//                int count = dataBase.login("lsk", "lsk1998");
//                Log.i(TAG, String.valueOf(count));
                //修改密码
                /*DataBase dataBase=new DataBase(Activity_selected.this);
                dataBase.setpasswd("lsk","lsk1998","lsk19981998");*/
                Intent intent=new Intent(Activity_selected.this, Activity_game.class);
                intent.putExtra("time",time);
                intent.putExtra("user",getIntent().getStringExtra("user"));
                startActivity(intent);

            }
        });
        //高级难度
        button_max.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int time=400;
                /*登陆测试
                DataBase dataBase=new DataBase(Activity_selected.this);
                int count = dataBase.login("lsk222", "lsk1998");
                Log.i(TAG, String.valueOf(count));
                //返回值为1则跳转，返回值为0则弹出
                */
                Intent intent=new Intent(Activity_selected.this, Activity_game.class);
                intent.putExtra("time",time);
                intent.putExtra("user",getIntent().getStringExtra("user"));
                startActivity(intent);
            }
        });
        //高分榜
        button_top.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(Activity_selected.this,Activity_top.class));
            }
        });
        //关于作者
        button_autor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //时间加长版的Toast
                for (int i = 0; i < 2; i++) {
                    Toast.makeText(Activity_selected.this,getResources().getString(R.string.autor),Toast.LENGTH_LONG).show();
                }
            }
        });



    }
}
